| 1 |
<?php |
| 2 |
/* @param string $meta Meta name. |
| 3 |
* @param array $details Contains the details for the field. |
| 4 |
* @param string $value Contains input value; |
| 5 |
* @param string $context Context where the function is used. Depending on it some actions are preformed.; |
| 6 |
* @return string $element input element html string. */ |
| 7 |
|
| 8 |
$args = apply_filters( 'wck-cpt-select-args', array( 'post_type' => $details['cpt'], 'orderby' => 'menu_order title', 'order' => 'ASC', 'posts_per_page' => '200', 'post_status' => 'publish' ), $details ); |
| 9 |
|
| 10 |
$cpt_query = new WP_Query($args); |
| 11 |
|
| 12 |
if( !empty( $cpt_query->posts ) ){ |
| 13 |
$element .= '<select name="'. esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $details['title'], $details ) ) .'" id="'; |
| 14 |
if( !empty( $frontend_prefix ) ) |
| 15 |
$element .= $frontend_prefix; |
| 16 |
$element .= esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $details['title'], $details ) ) .'" class="mb-user-select mb-field" >'; |
| 17 |
$element .= '<option value="">'. __('...Chose', 'wck') .'</option>'; |
| 18 |
foreach( $cpt_query->posts as $cpt ){ |
| 19 |
if ( $cpt->post_title == '' ) |
| 20 |
$cpt->post_title = 'No title. ID: ' . $cpt->ID; |
| 21 |
|
| 22 |
$element .= '<option value="'. esc_attr( $cpt->ID ) .'" '. selected( $cpt->ID, $value, false ) .' >'. esc_html( $cpt->post_title ) .'</option>'; |
| 23 |
} |
| 24 |
$element .= '</select>'; |
| 25 |
} |
| 26 |
?> |